revXMLNumberOfChildren
Type
function
Summary
Returns the number of child nodes under the specified node in an XML tree.
Syntax
revXMLNumberOfChildren(<treeID>, <startNode>, <childName> [, <depth>])
Description
Use the revXMLNumberOfChildren function to find out how many child nodes a parent node has, or to find out how many of a particular kind of child nodes it has.
If the revXMLNumberOfChildren function encounters an error, it returns an error message starting with "xmlerr".
The revXMLNumberOfChildren function is part of the XML library. To ensure that the function works in a standalone application, you must include this custom library when you create your standalone. In the Inclusions pane of the Standalone Application Settings window, make sure the "XML" checkbox is checked.
Parameters
Name | Type | Description |
---|---|---|
treeID | The number returned by the revXMLCreateTree or revXMLCreateTreeFromFile function when you created the XML tree. | |
startNode | The path to the node whose child nodes you want to count. | |
childName | string | A string specifying which child nodes to count. If it is empty, all child nodes are counted. Otherwise, only child nodes whose name matches the childName are counted. |
depth | The depth specifies how many generations to count. If you specify 0, only the parentNode's direct child nodes are counted, but not their child nodes. If you specify 1, the parentNode's child nodes are counted, along with their child nodes. To count all generations, specify -1 as the depth. |
Examples
revXMLNumberOfChildren(3,myNode,,-1)
repeat for revXMLNumberOfChildren(theTree,theNode,"Book",1) times
Related
control structure: function
function: revXMLChildContents, revXMLFirstChild, revXMLChildNames
glossary: LiveCode custom library, return, XML tree, child node, Standalone Application Settings, standalone application, non-negative, node, parent node
keyword: integer
library: XML library
Compatibility and Support
Introduced
LiveCode 2.0
OS
mac
windows
linux
ios
android
Platforms
desktop
server
mobile